// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require("base");
	var router = require("../hash/pageRouter");
	var dialog = require("dialog");
	var validate = require("validate");
	var databind = require("databind");
	var css_detail_info = require("./clientManage_certification.css");
	var html_auditState_Yes = require("../client/clientManage_auditStateYes.html");
	var html_auditState_No = require("../client/clientManage_auditStateNo.html");
	var html_activeCard = require("./html_activeCard.html");
	var html_adjustTemporary = require("./html_adjustTemporary.html");
	var tools = require("tools");
	var html_addFollowPerson = require("./html_addFollowPerson.html");
	var html_addCommission = require("./html_addCommission.html");
	var isCard;
	var html_startAndStopFinanceFollowPerson = require("./html_startAndStopFinanceFollowPerson.html");
	var html_updateShortName = require("./html_updateShortName.html");
	var tools = require("tools");
	var interestRate;
	var constant = require("constant");
	var penalInterest;
	
	var pageIndex = 1,
		pageSize = 20,
		totalPageCount = 1,
		totalRecordCount = 0; //分页初始化
	var enterpriseId = "";
	var businessLicenceImage = "";
	var certificateImage = "";
	var legalPersonFrontImage = "";
	var legalPersonBackImage = "";
	var qualificationsImage = "";
	var creditReportImage = "";
	var enterpriseCode;
	var init = function(page) {
		enterpriseId = page.params.enterpriseId || base.getUrlParam("enterpriseId");
		$(".nav_active").removeClass("nav_active1");
		$(".enterpriseInfo").addClass("nav_active1");
		initEvent();
		inquireEnterpriseDetail(enterpriseId);
		router.init();
		new PCAS("province","city","district");
	};
	
	var initEvent = function() {
		//若未登录，则返回登陆页面
		if (base.getData("sid") == null || base.getData("sid") == "" || base.getData("sid") == undefined) {
			location.href = "../login/login.html";
		}
	}
	
	//查询企业详细信息
	var inquireEnterpriseDetail = function(enterpriseId) {
		base.fnAjax({
			action: "inquireEnterpriseDetail.json",
			oData: {
				enterpriseId: enterpriseId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					juicer.register("getValueByKey", constant.getValueByKey);
					
					enterpriseCode = data.datas[0].enterpriseCode;
					if (data.datas[0].enterpriseGradeEvaluationDetail != null) {
						databind.fillForm($("#clientManage_certification"), data.datas[0]);
					}
					$(".clientManage_certification select[name=city]").html('<option value="'+data.datas[0].city+'">'+data.datas[0].city+'</option>');
				} else {
					base.alert(2, data.message);
				}
			}
		});
		
		//认证提交
		$(".submit").unbind("click").click(function(){
			enterpriseCertification();
		});
		
	};
	
	//认证企业
	var enterpriseCertification = function() {
		var certification = base.parseForm($(".clientManage_certification"));
		delete certification.district;
		base.fnAjax({
			action: 'informationCheck.json',
			async: false,
			oData: certification,
			fnSuccess: function(data) {
				if (data.status == 200) {
					base.alert(1, "认证成功！");
				} else {
					base.alert(3, data.message);
				}
			}
		});
		
	};
	
	
	
	return {
		init: init
	};
});